<template>
    <view class="menu">
        <view class="menu_item flex_b" @click="pagePush('个人信息')">
            <view class="menu_item_l">
                <image src="@/static/images/mine/icon_userinfo.png" mode="widthFix" />
                <text>个人信息</text>
            </view>
            <view class="menu_item_r">
                <image src="@/static/images/customerPage/icon_arrow.png" />
            </view>
        </view>
        <view class="menu_item flex_b" @click="pagePush('我的订单')">
            <view class="menu_item_l">
                <image src="@/static/images/mine/icon_myorder.png" mode="widthFix" />
                <text>我的订单</text>
            </view>
            <view class="menu_item_r">
                <image src="@/static/images/customerPage/icon_arrow.png" />
            </view>
        </view>
        <view class="menu_item flex_b" v-if="role == 'worker'" @click="pagePush('我的钱包')">
            <view class="menu_item_l">
                <image src="@/static/images/mine/icon_mywallet.png" mode="widthFix" />
                <text>我的钱包</text>
            </view>
            <view class="menu_item_r">
                <image src="@/static/images/customerPage/icon_arrow.png" />
            </view>
        </view>
        <view class="menu_item flex_b" @click="pagePush('公众号')">
            <view class="menu_item_l">
                <image src="@/static/images/mine/icon_gzh.png" mode="widthFix" />
                <text>关注公众号<text v-if="checkMemberMpResult" class="tips">(已关注)</text></text>
            </view>
            <view class="menu_item_r">
                <image src="@/static/images/customerPage/icon_arrow.png" />
            </view>
        </view>
        <!-- <view class="menu_item flex_b" @click="pagePush('获取code')">
            <view class="menu_item_l">
                <image src="@/static/images/mine/icon_mywallet.png" mode="widthFix" />
                <text>获取code</text>
            </view>
            <view class="menu_item_r">
                <image src="@/static/images/customerPage/icon_arrow.png" />
            </view>
        </view> -->
    </view>
</template>

<script setup lang="ts">
const props = withDefaults(defineProps<{
    isLogin: boolean
    checkMemberMpResult: boolean
}>(), {
    isLogin: false,
    checkMemberMpResult: false
})
const role = uni.getStorageSync('role')
const pagePush = ((val: string) => {
    if (!props.isLogin) return
    switch (val) {
        case '个人信息':
            uni.navigateTo({
                url: "/pages/mine/userInfo/userInfo"
            })
            break;
        case '我的订单':
            uni.setStorageSync('loadData', true)
            const url = role === 'worker' ? '/pages/tabbar/workerOrder/workerOrder' : '/pages/tabbar/customerOrder/customerOrder'
            uni.switchTab({
                url
            })
            break;
        case '我的钱包':
            uni.navigateTo({
                url: "/pages/mine/wallet/wallet"
            })
            break;
        case '公众号':
            uni.navigateTo({
                url: '/pages/mine/official/official'
            })
            break;
        case '获取code':
            uni.navigateTo({
                url: "/pages/test/test"
            })
            break;
    }
})

</script>

<style lang="scss" scoped>
.menu {
    width: 698rpx;
    background: #FFFFFF;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    padding: 0 24rpx;
    box-sizing: border-box;
    margin: 20rpx auto;

    .menu_item {
        width: 100%;
        height: 96rpx;
        border-bottom: 2rpx solid #F8F8F8;

        .menu_item_l {
            height: 96rpx;
            display: flex;
            align-items: center;
            font-weight: 500;
            font-size: 28rpx;
            color: #222222;

            image {
                width: 32rpx;
                margin-right: 20rpx;
            }
        }

        .menu_item_r {
            image {
                width: 12rpx;
                height: 20rpx;
            }
        }
    }
}
.tips{
    font-size: 22rpx;
    color: #888888;
    margin-left: 12rpx;
}
</style>